package com.cy.ppj.web.admin.statistics;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.ppj.model.Result;
import com.cy.ppj.model.query.statistics.ChannelUserGroupByCityStatisticsQuery;
import com.cy.ppj.model.query.statistics.OrderGroupByCityStatisticsQuery;
import com.cy.ppj.model.vo.admin.statistics.ChannelUserGroupByCityStatisticsVO;
import com.cy.ppj.model.vo.admin.statistics.CommissionAndWithholdStatisticsVO;
import com.cy.ppj.model.vo.admin.statistics.OrderGroupByCityStatisticsVO;
import com.cy.ppj.model.vo.admin.statistics.OrderLoanRateStatisticsVO;
import com.cy.ppj.model.vo.admin.statistics.StatisticsOrderLoanCountVO;
import com.cy.ppj.model.vo.admin.statistics.StatisticsOrderLoanVO;
import com.cy.ppj.model.vo.admin.statistics.StatisticsUserCountVO;
import com.cy.ppj.model.vo.admin.statistics.StatisticsUserVO;
import com.cy.ppj.model.vo.admin.statistics.UserStructureStatisticsVO;
import com.cy.ppj.service.statistics.DataStatisticsService;
import com.cy.ppj.web.BaseController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 后台-数据统计
 *
 * @author: tanyilin
 * @create: 2018年10月17日 下午2:10:37
 */
@Slf4j
@RestController
@RequestMapping("/admin/data/statistics")
@Api(tags = "后台-数据统计")
public class AdminDataStatisticsController extends BaseController{

	@Autowired
	private DataStatisticsService dataStatisticsService;
	
	@ApiOperation("用户数量统计")
	@GetMapping("/user/count")
	public Result<StatisticsUserCountVO> selectStatisticsUserCountVO() {
		StatisticsUserCountVO statisticsUserCountVO = dataStatisticsService.selectStatisticsUserCountVO();
		return ok("", statisticsUserCountVO);
	}
	
	@ApiOperation("用户注册数据统计")
	@GetMapping("/user/register")
	public Result<List<StatisticsUserVO>> userRegisterStatistics() {
		List<StatisticsUserVO> list = dataStatisticsService.selectStatisticsUserVOs();
		return ok("", list);
	}
	
	@ApiOperation("放款量数量统计")
	@GetMapping("/order/loan/count")
	public Result<StatisticsOrderLoanCountVO> selectStatisticsOrderLoanCountVO() {
		StatisticsOrderLoanCountVO vo = dataStatisticsService.selectStatisticsOrderLoanCountVO();
		return ok("", vo);
	}
	
	@ApiOperation("放款量数据统计")
	@GetMapping("/order/loan")
	public Result<List<StatisticsOrderLoanVO>> selecStatisticsOrderLoanVOs() {
		List<StatisticsOrderLoanVO> list = dataStatisticsService.selectStatisticsOrderLoanVOs();
		return ok("", list);
	}
	
	@ApiOperation("提单量数量统计")
	@GetMapping("/order/apply/count")
	public Result<StatisticsOrderLoanCountVO> selectStatisticsOrderCountVO() {
		StatisticsOrderLoanCountVO vo = dataStatisticsService.selectStatisticsOrderCountVO();
		return ok("", vo);
	}
	
	@ApiOperation("提单量数据统计")
	@GetMapping("/order/apply")
	public Result<List<StatisticsOrderLoanVO>> selecStatisticsOrderVOs() {
		List<StatisticsOrderLoanVO> list = dataStatisticsService.selectStatisticsOrderVOs();
		return ok("", list);
	}
	
	@ApiOperation("佣金、代扣统计")
	@GetMapping("/commission/withhold")
	public Result<CommissionAndWithholdStatisticsVO> statistics() {
		CommissionAndWithholdStatisticsVO vo = dataStatisticsService.selectCommissionAndWithholdStatisticsVO();
		return ok("", vo);
	}
	
	@ApiOperation("用户结构统计")
	@GetMapping("/user/structure")
	public Result<List<UserStructureStatisticsVO>> selectUserStructureStatisticsVO() {
		List<UserStructureStatisticsVO> list = dataStatisticsService.selectUserStructureStatisticsVOs();
		return ok("", list);
	}
	
	@ApiOperation("放款率")
	@GetMapping("/order/loan/rate")
	public Result<List<OrderLoanRateStatisticsVO>> selectOrderLoanRateStatisticsVO() {
		List<OrderLoanRateStatisticsVO> list = dataStatisticsService.selectOrderLoanRateStatisticsVOs();
		return ok("", list);
	}
	
	@ApiOperation("产品放款量")
	@GetMapping("/product/order/loan/amount")
	public Result<List<OrderGroupByCityStatisticsVO>> selectOrderLoanAmountGroupByCityStatisticsVOs(OrderGroupByCityStatisticsQuery query) {
		List<OrderGroupByCityStatisticsVO> list = dataStatisticsService.selectOrderLoanAmountGroupByCityStatisticsVOs(query);
		return ok("", list);
	}
	
	@ApiOperation("产品提单量")
	@GetMapping("/product/order/apply/count")
	public Result<List<OrderGroupByCityStatisticsVO>> selectOrderCountGroupByCityStatisticsVOs(OrderGroupByCityStatisticsQuery query) {
		List<OrderGroupByCityStatisticsVO> list = dataStatisticsService.selectOrderCountGroupByCityStatisticsVOs(query);
		return ok("", list);
	}
	 
	@ApiOperation("渠道员注册量")
	@GetMapping("/channel/user/register/count")
	public Result<List<ChannelUserGroupByCityStatisticsVO>> selectchannelUserGroupByCityStatisticsVOs(ChannelUserGroupByCityStatisticsQuery query) {
		List<ChannelUserGroupByCityStatisticsVO> list = dataStatisticsService.selectchannelUserGroupByCityStatisticsVOs(query);
		return ok("", list);
	}
	
}
